from django.shortcuts import render

# Create your views here.
from rest_framework.generics import ListAPIView
from .models import Banner, Nav
from .serializers import BannerModelSerializer, NavModelSerializer
from luffyapi.settings import constants


class BannerListApiView(ListAPIView):
    """ 轮播广告 """
    queryset = Banner.objects.filter(is_show=True, is_deleted=False).order_by("-orders", "-id")[
               :constants.BANNER_LENGTH]
    # 序列化器
    serializer_class = BannerModelSerializer


class HeaderNavListApiView(ListAPIView):
    """ 导航 """
    queryset = Nav.objects.filter(is_show=True, is_deleted=False, position=1).order_by("-orders", "-id")[
               :constants.HEADER_NAV_LENGTH]
    # 序列化器
    serializer_class = NavModelSerializer


class FooterNavListApiView(ListAPIView):
    """ 导航 """
    queryset = Nav.objects.filter(is_show=True, is_deleted=False, position=2).order_by("-orders", "-id")[
               :constants.FOOTER_NAV_LENGTH]
    # 序列化器
    serializer_class = NavModelSerializer
